﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace CutAways
{
    public static class Fps
    {
        private static Stopwatch watch;

        private static float t1;
        private static float t0;
        private static float minFps;
        private static float fps;

        static Fps()
        {
            t1 = t0 = 0;
            minFps = 30;
            fps = 30;

            watch = new Stopwatch();
            watch.Start();
        }

        public static void Measure()
        {
            watch.Stop();
            t1 = watch.ElapsedMilliseconds;
            fps = (float)1000 / (float)(t1 - t0);
            t0 = t1;
            watch.Reset();
            watch.Start();
        }

        public static float FPS
        {
            get { return (fps > minFps) ? fps : minFps; }
        }

        public static float realFps
        {
            get { return fps; }
        }

    }
}
